package com.arceus.leetcode;

import java.util.ArrayList;
import java.util.List;

/**
 * @author : iron
 * @version : 1.0.0
 * @date : 2:29 PM 2019/3/4
 */

public class t118 {

    public List<List<Integer>> generate(int numRows) {
        List<List<Integer>> result = new ArrayList<>();
        int[][] three = new int[numRows][numRows];
        for (int i = 0; i < numRows; i++) {
            List<Integer> tmp = new ArrayList<>();
            three[i][0] = 1;
            three[i][i] = 1;
            for (int j = 0; j <= i; j++) {
                if (j > 0 && j < i) {
                    three[i][j] = three[i - 1][j - 1] + three[i - 1][j];
                }
                tmp.add(three[i][j]);
            }
            result.add(tmp);
        }
        return result;
    }
}
